package com.hzqy.web.ac;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hzqy.service.cast.CastServiceBean;
import com.hzqy.web.vo.CmCastVo;

@Controller
@RequestMapping("/cast")
public class CastAction{
	@Resource
	private CastServiceBean castServiceBean;
	
	private final String picType = "演职";

	@RequestMapping("/select_cast_list")
	@ResponseBody
	public Object selectCastVoList(CmCastVo cmCastVo, int page, int rows) {
		return castServiceBean.selectCastList(cmCastVo,page,rows);
	}
	@RequestMapping("/insert_cast")
	@ResponseBody
	public Object insertCastVo(CmCastVo cmCastVo,String picJson) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		int flag = castServiceBean.insertCast(cmCastVo,picJson);
		if(flag > 0) {
			resultMap.put("success", true);
			resultMap.put("result","新增成功!");
		} else {
			resultMap.put("success", true);
			resultMap.put("result","新增失败!flag="+flag);
		}
		return resultMap;
	}
	@RequestMapping("/update_cast")
	@ResponseBody
	public Object updateCastVo(CmCastVo cmCastVo, String picJson) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		int flag = castServiceBean.updateCast(cmCastVo,picJson,picType);
		if(flag > 0) {
			resultMap.put("success", true);
			resultMap.put("result","更新成功!");
		} else {
			resultMap.put("success", true);
			resultMap.put("result","更新失败!flag="+flag);
		}
		return resultMap;
	}
	@RequestMapping("/delete_cast")
	@ResponseBody
	public Object deleteCastVo(int f_cast_id) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		int flag = castServiceBean.deleteCast(f_cast_id);
		resultMap.put("resultTitle", "删除结果");
		if(flag>0) {
			resultMap.put("success", true);
			resultMap.put("result","删除成功!");
		} else {
			resultMap.put("success", false);
			resultMap.put("result","删除失败!");
		}
		return resultMap;
	}
	@RequestMapping("/select_cast")
	@ResponseBody
	public Object selectCastVo(int f_cast_id) {
		return castServiceBean.selectCastVo(f_cast_id);
	}
}